package net.amsoft.iservice.util;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;


/*
 * Inspired by and acknowledgements to the article author:
 * http://www.javaworld.com/javaworld/jw-05-2004/jw-0524-i18n.html
 */
public class UTF8EncodingFilter implements Filter {

	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub

	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain filterChain) throws IOException, ServletException {
		request.setCharacterEncoding( "UTF-8" );
        response = new UTF8EncodingServletResponse( (HttpServletResponse) response );
        filterChain.doFilter( request, response );
	}

	public void destroy() {
		// TODO Auto-generated method stub

	}

}
